home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / AIncludes / TextUtils.a < prev    next >
Encoding:
Text File  |  1998-08-17  |  11.7 KB  |  430 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        TextUtils.a
  3. ;
  4. ;    Contains:    Text Utilities Interfaces.
  5. ;
  6. ;    Version:    Technology:    System 7.5+
  7. ;                Release:    Universal Interfaces 3.2
  8. ;
  9. ;    Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved.
  10. ;
  11. ;    Bugs?:        For bug reports, consult the following page on
  12. ;                the World Wide Web:
  13. ;
  14. ;                    http://developer.apple.com/bugreporter/
  15. ;
  16. ;
  17.     IF &TYPE('__TEXTUTILS__') = 'UNDEFINED' THEN
  18. __TEXTUTILS__ SET 1
  19.  
  20.     IF &TYPE('__MACTYPES__') = 'UNDEFINED' THEN
  21.     include 'MacTypes.a'
  22.     ENDIF
  23.     IF &TYPE('__NUMBERFORMATTING__') = 'UNDEFINED' THEN
  24.     include 'NumberFormatting.a'
  25.     ENDIF
  26.     IF &TYPE('__STRINGCOMPARE__') = 'UNDEFINED' THEN
  27.     include 'StringCompare.a'
  28.     ENDIF
  29.     IF &TYPE('__DATETIMEUTILS__') = 'UNDEFINED' THEN
  30.     include 'DateTimeUtils.a'
  31.     ENDIF
  32.  
  33. ;
  34. ;    Here are the current System 7 routine names and the translations to the older forms.
  35. ;    Please use the newer forms in all new code and migrate the older names out of existing
  36. ;    code as maintainance permits.
  37. ;    
  38. ;    NEW NAME                    OLD NAMEs                    OBSOLETE FORM (no script code)
  39. ;
  40. ;    FindScriptRun
  41. ;    FindWordBreaks                                            NFindWord, FindWord
  42. ;    GetIndString            
  43. ;    GetString
  44. ;    Munger
  45. ;    NewString                
  46. ;    SetString                
  47. ;    StyledLineBreak
  48. ;    TruncString
  49. ;    TruncText
  50. ;
  51. ;    UpperString ($A054)            UprString, UprText
  52. ;    UppercaseText                SCUpperText (a only)        UpperText ($A456)
  53. ;    LowercaseText                                            LwrString, LowerText, LwrText ($A056)
  54. ;    StripDiacritics                                            StripText ($A256)
  55. ;    UppercaseStripDiacritics                                StripUpperText ($A656)
  56. ;
  57. ;
  58. ;
  59.  
  60.  
  61. ;  Type for truncWhere parameter in TruncString, TruncText 
  62. ; typedef short                         TruncCode
  63.  
  64.  
  65.                                                             ; Constants for truncWhere argument in TruncString and TruncText 
  66. truncEnd                        EQU        0                    ; Truncate at end 
  67. truncMiddle                        EQU        $4000                ; Truncate in middle 
  68. smTruncEnd                        EQU        0                    ; Truncate at end - obsolete 
  69. smTruncMiddle                    EQU        $4000                ; Truncate in middle - obsolete 
  70.  
  71.                                                             ; Constants for TruncString and TruncText results 
  72. notTruncated                    EQU        0                    ; No truncation was necessary 
  73. truncated                        EQU        1                    ; Truncation performed 
  74. truncErr                        EQU        -1                    ; General error 
  75. smNotTruncated                    EQU        0                    ; No truncation was necessary - obsolete 
  76. smTruncated                        EQU        1                    ; Truncation performed    - obsolete 
  77. smTruncErr                        EQU        -1                    ; General error - obsolete 
  78. ; typedef SInt8                         StyledLineBreakCode
  79.  
  80.  
  81. smBreakWord                        EQU        0
  82. smBreakChar                        EQU        1
  83. smBreakOverflow                    EQU        2
  84. ScriptRunStatus            RECORD 0
  85. script                     ds.b    1                ; offset: $0 (0)
  86. runVariant                 ds.b    1                ; offset: $1 (1)
  87. sizeof                     EQU *                    ; size:   $2 (2)
  88.                         ENDR
  89. BreakTable                RECORD 0
  90. charTypes                 ds.b    256                ; offset: $0 (0)
  91. tripleLength             ds.w    1                ; offset: $100 (256)
  92. triples                     ds.w    1                ; offset: $102 (258) <-- really an array of length one
  93. sizeof                     EQU *                    ; size:   $104 (260)
  94.                         ENDR
  95. ; typedef struct BreakTable *            BreakTablePtr
  96.  
  97. NBreakTable                RECORD 0
  98. flags1                     ds.b    1                ; offset: $0 (0)
  99. flags2                     ds.b    1                ; offset: $1 (1)
  100. version                     ds.w    1                ; offset: $2 (2)
  101. classTableOff             ds.w    1                ; offset: $4 (4)
  102. auxCTableOff             ds.w    1                ; offset: $6 (6)
  103. backwdTableOff             ds.w    1                ; offset: $8 (8)
  104. forwdTableOff             ds.w    1                ; offset: $A (10)
  105. doBackup                 ds.w    1                ; offset: $C (12)
  106. length                     ds.w    1                ; offset: $E (14)        ;  length of NBreakTable 
  107. charTypes                 ds.b    256                ; offset: $10 (16)
  108. tables                     ds.w    1                ; offset: $110 (272) <-- really an array of length one
  109. sizeof                     EQU *                    ; size:   $112 (274)
  110.                         ENDR
  111. ; typedef struct NBreakTable *            NBreakTablePtr
  112.  
  113. ;  The following functions are new names that work on 68k and PowerPC
  114. ;
  115. ; pascal long Munger(Handle h, long offset, const void *ptr1, long len1, const void *ptr2, long len2)
  116. ;
  117.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  118.         _Munger:    OPWORD    $A9E0
  119.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  120.         IMPORT_CFM_FUNCTION Munger
  121.     ENDIF
  122.  
  123. ;
  124. ; pascal StringHandle NewString(ConstStr255Param theString)
  125. ;
  126.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  127.         _NewString:    OPWORD    $A906
  128.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  129.         IMPORT_CFM_FUNCTION NewString
  130.     ENDIF
  131.  
  132. ;
  133. ; pascal void SetString(StringHandle theString, ConstStr255Param strNew)
  134. ;
  135.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  136.         _SetString:    OPWORD    $A907
  137.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  138.         IMPORT_CFM_FUNCTION SetString
  139.     ENDIF
  140.  
  141. ;
  142. ; pascal StringHandle GetString(short stringID)
  143. ;
  144.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  145.         _GetString:    OPWORD    $A9BA
  146.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  147.         IMPORT_CFM_FUNCTION GetString
  148.     ENDIF
  149.  
  150. ;
  151. ; pascal StyledLineBreakCode StyledLineBreak(Ptr textPtr, long textLen, long textStart, long textEnd, long flags, Fixed *textWidth, long *textOffset)
  152. ;
  153.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  154.         Macro
  155.         _StyledLineBreak
  156.             move.l              #$821CFFFE,-(sp)
  157.             dc.w                $A8B5
  158.         EndM
  159.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  160.         IMPORT_CFM_FUNCTION StyledLineBreak
  161.     ENDIF
  162.  
  163. ;
  164. ; pascal short TruncString(short width, Str255 theString, TruncCode truncWhere)
  165. ;
  166.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  167.         Macro
  168.         _TruncString
  169.             move.l              #$8208FFE0,-(sp)
  170.             dc.w                $A8B5
  171.         EndM
  172.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  173.         IMPORT_CFM_FUNCTION TruncString
  174.     ENDIF
  175.  
  176. ;
  177. ; pascal short TruncText(short width, Ptr textPtr, short *length, TruncCode truncWhere)
  178. ;
  179.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  180.         Macro
  181.         _TruncText
  182.             move.l              #$820CFFDE,-(sp)
  183.             dc.w                $A8B5
  184.         EndM
  185.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  186.         IMPORT_CFM_FUNCTION TruncText
  187.     ENDIF
  188.  
  189. ;
  190. ; pascal void FindWordBreaks(Ptr textPtr, short textLength, short offset, Boolean leadingEdge, BreakTablePtr breaks, OffsetTable offsets, ScriptCode script)
  191. ;
  192.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  193.         Macro
  194.         _FindWordBreaks
  195.             move.l              #$C012001A,-(sp)
  196.             dc.w                $A8B5
  197.         EndM
  198.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  199.         IMPORT_CFM_FUNCTION FindWordBreaks
  200.     ENDIF
  201.  
  202. ;
  203. ; pascal void LowercaseText(Ptr textPtr, short len, ScriptCode script)
  204. ;
  205.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  206.         Macro
  207.         _LowercaseText
  208.             move.w              #$0000,-(sp)
  209.             move.l              #$800AFFB6,-(sp)
  210.             dc.w                $A8B5
  211.         EndM
  212.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  213.         IMPORT_CFM_FUNCTION LowercaseText
  214.     ENDIF
  215.  
  216. ;
  217. ; pascal void UppercaseText(Ptr textPtr, short len, ScriptCode script)
  218. ;
  219.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  220.         Macro
  221.         _UppercaseText
  222.             move.w              #$0400,-(sp)
  223.             move.l              #$800AFFB6,-(sp)
  224.             dc.w                $A8B5
  225.         EndM
  226.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  227.         IMPORT_CFM_FUNCTION UppercaseText
  228.     ENDIF
  229.  
  230. ;
  231. ; pascal void StripDiacritics(Ptr textPtr, short len, ScriptCode script)
  232. ;
  233.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  234.         Macro
  235.         _StripDiacritics
  236.             move.w              #$0200,-(sp)
  237.             move.l              #$800AFFB6,-(sp)
  238.             dc.w                $A8B5
  239.         EndM
  240.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  241.         IMPORT_CFM_FUNCTION StripDiacritics
  242.     ENDIF
  243.  
  244. ;
  245. ; pascal void UppercaseStripDiacritics(Ptr textPtr, short len, ScriptCode script)
  246. ;
  247.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  248.         Macro
  249.         _UppercaseStripDiacritics
  250.             move.w              #$0600,-(sp)
  251.             move.l              #$800AFFB6,-(sp)
  252.             dc.w                $A8B5
  253.         EndM
  254.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  255.         IMPORT_CFM_FUNCTION UppercaseStripDiacritics
  256.     ENDIF
  257.  
  258. ;
  259. ; pascal ScriptRunStatus FindScriptRun(Ptr textPtr, long textLen, long *lenUsed)
  260. ;
  261.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  262.         Macro
  263.         _FindScriptRun
  264.             move.l              #$820C0026,-(sp)
  265.             dc.w                $A8B5
  266.         EndM
  267.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  268.         IMPORT_CFM_FUNCTION FindScriptRun
  269.     ENDIF
  270.  
  271.  
  272. ;      The following functions are old names, but are required for PowerPC builds
  273. ;      because InterfaceLib exports these names, instead of the new ones.
  274.  
  275.  
  276.  
  277. ;
  278. ; pascal void FindWord(Ptr textPtr, short textLength, short offset, Boolean leadingEdge, BreakTablePtr breaks, OffsetTable offsets)
  279. ;
  280.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  281.         Macro
  282.         _FindWord
  283.             move.l              #$8012001A,-(sp)
  284.             dc.w                $A8B5
  285.         EndM
  286.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  287.         IMPORT_CFM_FUNCTION FindWord
  288.     ENDIF
  289.  
  290. ;
  291. ; pascal void NFindWord(Ptr textPtr, short textLength, short offset, Boolean leadingEdge, NBreakTablePtr nbreaks, OffsetTable offsets)
  292. ;
  293.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  294.         Macro
  295.         _NFindWord
  296.             move.l              #$8012FFE2,-(sp)
  297.             dc.w                $A8B5
  298.         EndM
  299.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  300.         IMPORT_CFM_FUNCTION NFindWord
  301.     ENDIF
  302.  
  303.  
  304. ;   On 68K machines, LwrText, LowerText, StripText, UpperText and StripUpperText
  305. ;   return an error code in register D0, but System 7 PowerMacs do not emulate
  306. ;   this properly, so checking D0 is unreliable.
  307.  
  308.  
  309.  
  310. ;
  311. ; pascal void LwrText(Ptr textPtr, short len)
  312. ;
  313.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  314.         ; parameters:
  315.         ;    textPtr         => A0
  316.         ;    len             => D0
  317.         _LwrText:    OPWORD    $A056
  318.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  319.         IMPORT_CFM_FUNCTION LwrText
  320.     ENDIF
  321.  
  322. ;
  323. ; pascal void LowerText(Ptr textPtr, short len)
  324. ;
  325.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  326.         ; parameters:
  327.         ;    textPtr         => A0
  328.         ;    len             => D0
  329.         _LowerText:    OPWORD    $A056
  330.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  331.         IMPORT_CFM_FUNCTION LowerText
  332.     ENDIF
  333.  
  334. ;
  335. ; pascal void StripText(Ptr textPtr, short len)
  336. ;
  337.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  338.         ; parameters:
  339.         ;    textPtr         => A0
  340.         ;    len             => D0
  341.         _StripText:    OPWORD    $A256
  342.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  343.         IMPORT_CFM_FUNCTION StripText
  344.     ENDIF
  345.  
  346. ;
  347. ; pascal void UpperText(Ptr textPtr, short len)
  348. ;
  349.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  350.         ; parameters:
  351.         ;    textPtr         => A0
  352.         ;    len             => D0
  353.         _UpperText:    OPWORD    $A456
  354.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  355.         IMPORT_CFM_FUNCTION UpperText
  356.     ENDIF
  357.  
  358. ;
  359. ; pascal void StripUpperText(Ptr textPtr, short len)
  360. ;
  361.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  362.         ; parameters:
  363.         ;    textPtr         => A0
  364.         ;    len             => D0
  365.         _StripUpperText:    OPWORD    $A656
  366.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  367.         IMPORT_CFM_FUNCTION StripUpperText
  368.     ENDIF
  369.  
  370.  
  371. ;  The following are new names which are exported by InterfaceLib
  372.  
  373.     IF TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  374. ;
  375. ; extern void UpperString(BytePtr textPtr, UInt16 length)
  376. ;
  377.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  378.         ; parameters:
  379.         ;    textPtr         => A0
  380.         ;    length          => D0
  381.         _UpperString:    OPWORD    $A054
  382.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  383.         IMPORT_CFM_FUNCTION UpperString
  384.     ENDIF
  385.  
  386. ;
  387. ; extern void UpperStringMarks(BytePtr textPtr, UInt16 length)
  388. ;
  389.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  390.         ; parameters:
  391.         ;    textPtr         => A0
  392.         ;    length          => D0
  393.         _UpperStringMarks:    OPWORD    $A254
  394.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  395.         IMPORT_CFM_FUNCTION UpperStringMarks
  396.     ENDIF
  397.  
  398.     ELSE
  399. ;
  400. ; pascal void UpperString(Str255 theString, Boolean diacSensitive)
  401. ;
  402.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  403.         IMPORT_CFM_FUNCTION UpperString
  404.     ENDIF
  405.  
  406.     ENDIF
  407. ;  Old routine name but no new names are mapped to it:
  408. ;
  409. ; pascal void UprText(Ptr textPtr, short len)
  410. ;
  411.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  412.         ; parameters:
  413.         ;    textPtr         => A0
  414.         ;    len             => D0
  415.         _UprText:    OPWORD    $A054
  416.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  417.         IMPORT_CFM_FUNCTION UprText
  418.     ENDIF
  419.  
  420. ;
  421. ;    Functions for converting between C and Pascal Strings
  422. ;    (Previously in Strings.h)
  423. ;    
  424. ;
  425.  
  426.     ENDIF ; __TEXTUTILS__ 
  427.  
  428.